<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'rightPage.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="${base }/css/caas_style.css" />
	<script type="text/javascript" src="${base }/js/jquery/jquery-1.3.min.js"></script>
	<script type="text/javascript" src="${base}js/jquery/lhgdialog/lhgcore.min.js"></script>
	<script type="text/javascript" src="${base}js/jquery/lhgdialog/lhgdialog.min.js"></script>
	<script type="text/javascript">
		jQuery(document).ready(function(){
		  	var dg = frameElement.lhgDG; 			   
			dg.addBtn("confirm_id","确定",confirmClick);
			  			   
		    var param = dg.getArgs();
			var dirId = param.dirId;
			
			//右移
			jQuery("#btn_right").click(function(){
				var $sel = jQuery("#left_select option:selected");
				jQuery("#right_select").append($sel);
			});
			//左移
			jQuery("#btn_left").click(function(){
				var $sel = jQuery("#right_select option:selected");
				jQuery("#left_select").append($sel);
			});
			//全部右移
			jQuery("#btn_rightAll").click(function(){
				var $sel = jQuery("#left_select option");
				jQuery("#right_select").append($sel);
			});
			//全部左移
			jQuery("#btn_leftAll").click(function(){
				var $sel = jQuery("#right_select option");
				jQuery("#left_select").append($sel);
			});
			
			function confirmClick(){
				var userIds = [];
				var i = 0;
				jQuery("#right_select option").each(function(){
					userIds[i] = jQuery(this).val();
					i ++;
				});
				var param = {};
				param.userIds = userIds;
				param.dirId = dirId;
				jQuery.post("${base}/directory/saveRight",param,function(data,textStatus,jqXHR){
					//alert(data.success);
					if(data.success){
						alert("授权成功!");
					}else{
						alert("授权失败!");
					}	
					dg.cancel();	 
				},'json');
			}
		});
	</script>

  </head>

	<body>
		<div class="biaoge">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td colspan="6" class="biaoge_bg01">&nbsp; 
						目录授权列表 
					</td>
				</tr>
				<tr>
					<td>
						<table width="100%" border="0" cellspacing="1" cellpadding="0"
							class="FindAreaTable1" ID="DataGrid1">
							<tr>
								<td width="40%">
									待选人员列表<BR/>
									<select   multiple   Name='left_select'  size="10" id='left_select'  TABINDEX=1   style='width:170px'>   
										<c:forEach items="${leftList }" var="user">
											<option value="${user.id }">${user.fullName }(${user.userName })</option>
										</c:forEach>
									</select>
								</td>
								<td width="20%" align="center"> 
									<table border="0" cellspacing="0" cellpadding="0">
									<tr><td height="30" style="background-color:#EEECEC">
									<input type="button" value="  >  " class="anniu" id="btn_right"/>
									</td></tr>
									<tr><td height="30"  style="background-color:#EEECEC">
									<input type="button" value="  <  " class="anniu" id="btn_left"/>
									</td></tr>
									<tr><td height="30" style="background-color:#EEECEC">
									<input type="button" value=" >> " class="anniu" id="btn_rightAll"/>
									</td></tr>
									<tr><td height="30" style="background-color:#EEECEC">
									<input type="button" value=" << " class="anniu" id="btn_leftAll"/>
									</td></tr>
									</table>
								</td>
								<td width="40%">
									已选人员列表<BR/>
									<select   multiple   Name='right_select'   id='right_select'  size="10" TABINDEX=2   style='width:170px'>   
										<c:forEach items="${rightList }" var="user">
											<option value="${user.id }">${user.fullName }(${user.userName })</option>
										</c:forEach>								
									</select>
								</td>
							</tr>

						</table>
					</td>
				</tr>
			</table>
		</div>
	</body>
</html>
